/**
 *
 */
function check(){
    var phone=form.phone.value;
    var name=form.name.value;
    var password=form.password.value;
    var password2=form.password2.value;
    var toolphone=document.getElementById("toolphone");
    var toolname=document.getElementById("toolname");
    var toolpassword=document.getElementById("toolpassword");
    var toolpassword2=document.getElementById("toolpassword2");
    var len=0;
    var phoneEXp=/^[A-Za-z0-9]{4,40}$/;
    len=password.length;
    if (phone==""||phone==null){
        toolphone.innerHTML="账号不能为空";
        toolphone.style.color="red";
        return;
    }
    var ok = phoneEXp.test(phone);
    if (!ok){
        toolphone.innerHTML="账号格式错误";
        toolphone.style.color="red";
        return;
    }
        $.ajax({
            type: "POST",
            url:"ajaxPhone",
            dataType:"text",
            data:{"phone":phone},
            success:function (resp) {
               if (resp=="false") {
                   toolphone.innerHTML="账号已经被注册";
                   toolphone.style.color="red";
                   return;
               }
            }
        })


    if (name==""||name==null){
        toolphone.innerHTML="用户名不能为空";
        toolphone.style.color="red";
        toolphone.innerHTML="";
        return;
    }
    else if (password==""||password==null){
        toolpassword.innerHTML="密码不能为空";
        toolpassword.style.color="red";
        toolname.innerHTML="";
        toolname.style.color="red";
        return;
    }
    else if (password2==""||password2==null){
        toolpassword2.innerHTML="确认密码不能为空";
        toolpassword2.style.color="red";
        toolpassword.innerHTML="";
        toolpassword.style.color="red";
        toolname.innerHTML="";
        toolname.style.color="red";
        return;
    }
    else if (len<6){
        toolname.innerHTML="";
        toolpassword.innerHTML="密码不能少于6个字符";
    }
    else if (password!=password2){
        //alert(password==password2);
        toolpassword2.innerHTML="两次输入的密码不正确";
        toolpassword2.style.color="red";
        toolname.innerHTML="";
        toolname.style.color="red";
        toolpassword.innerHTML="";
        toolpassword.style.color="red";
        return;
    }
    else {
        toolname.innerHTML="";
        toolpassword.innerHTML="";
        toolpassword2.innerHTML="";
        document.getElementById("form").submit();
    }
}